package cn.weakup.designpattern.a_foreword.calculator02;

import java.util.Scanner;

/**
 * @author lixj
 * @version 1.0.0
 * @date 2022/6/2
 * @desc 优化：实现封装，将与控制台无关的类封装起来
 */
public class Calculator {

    public static void main(String[] args) {
        String flag;
        do {
            System.out.println("请输入第一个数字");
            Scanner scanner = new Scanner(System.in);
            String numberA = scanner.nextLine();
            System.out.println("请输入第二个数字");
            String numberB = scanner.nextLine();
            System.out.println("请输入运算符");
            String option = scanner.nextLine();

            String result = Operation.handleProgram(numberA, numberB, option);

            System.out.println("结果为：" + result);
            System.out.println("继续请按1，退出请按0");
            flag = scanner.nextLine();
        } while ("1".equals(flag));

    }
}
